﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace intheweel
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            Form2 form2 = new Form2();

            form2.Show();
        }


        private void button1_Click(object sender, EventArgs e)
        {
            var uid = textBox1.Text.Trim();

            var pwd = textBox2.Text.Trim(); 
            string connmit = "server = .; database = Blogs ; uid = sa ; pwd = chen5201314";

            SqlConnection sql = new SqlConnection(connmit);
            sql.Open();
            var sqlcmd = string.Format("select * from Users where Username = '{0}'and Password = '{1}'",uid,pwd);
            SqlCommand sqlCommand = new SqlCommand(sqlcmd,sql);
            var x = sqlCommand.ExecuteReader();

            if(x.Read())
            {
                MessageBox.Show("登录成功！欢迎您");
                login login = new login();
                login.Show();
                this.Hide();
            }

            else
            {
                MessageBox.Show("账户或密码错误，登录失败！");
            }
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }
    }
}
